package salary

// 修改支付方法
type ChangeMethodTransaction struct {
	ChangeEmployeeTransaction
	GetPaymentMethod func() PaymentMethod
}

func (c *ChangeMethodTransaction) Execute() {
	employee := GetDB().GetEmployee(c.EmployeeId)
	if employee.EmployeeId != 0 {
		c.Change(employee)
	}
}

func (c *ChangeMethodTransaction) Change(e Employee) {
	e.PaymentMethod = c.GetPaymentMethod()
}

//ChangeDirectTransaction
type ChangeDirectTransaction struct {
	ChangeEmployeeTransaction
	Bank    string
	Account string
}

func GetChangeDirectTransaction(employeeId int, bank string, account string) *ChangeDirectTransaction {
	c := &ChangeDirectTransaction{
		*GetChangeEmployeeTransaction(employeeId),
		bank,
		account,
	}
	c.ChangeEmployeeTransaction.Change = c.Change
	return c
}

func (c *ChangeDirectTransaction) GetPaymentMethod() PaymentMethod {
	return &DirectMethod{}
}

//ChangeHoldTransaction
type ChangeHoldTransaction struct {
	ChangeEmployeeTransaction
}

func GetChangeHoldTransaction(employeeId int) *ChangeHoldTransaction {
	c := &ChangeHoldTransaction{
		*GetChangeEmployeeTransaction(employeeId),
	}
	c.ChangeEmployeeTransaction.Change = c.Change
	return c
}

func (c *ChangeHoldTransaction) GetPaymentMethod() PaymentMethod {
	return &HoldMethod{}
}

//ChangeHoldTransaction
type ChangeMailTransaction struct {
	ChangeEmployeeTransaction
	Address string
}

func GetChangeMailTransaction(employeeId int, address string) *ChangeMailTransaction {
	c := &ChangeMailTransaction{
		*GetChangeEmployeeTransaction(employeeId),
		address,
	}
	c.ChangeEmployeeTransaction.Change = c.Change
	return c
}

func (c *ChangeMailTransaction) GetPaymentMethod() PaymentMethod {
	return &MailMethod{}
}

